using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;

namespace UselessExplorer
{
    public partial class frmProperties : Form
    {
        public frmProperties()
        {
            InitializeComponent();
        }

        private string filePath;
        private bool isDirectory;

        public bool IsDirectory
        {
            get { return isDirectory; }
            set { isDirectory = value; }
        }

        public string FilePath
        {
            get { return filePath; }
            set { filePath = value; }
        }

        public frmProperties(string path, bool isDirectory)
        {
            InitializeComponent();
            FilePath = path;
            IsDirectory = isDirectory;
        }

        private void frmProperties_Load(object sender, EventArgs e)
        {
            this.Text = UselessExplorer.Properties.UselessResources.frmPropertiesTitle;
            clsGlobal cg = clsGlobal.Instance;
            this.Left = cg.FormLeft;
            this.Top = cg.FormTop;
            try
            {
                if (!IsDirectory)
                {
                    if (FilePath != null)
                    {
                        FileInfo fi = new FileInfo(FilePath);
                        this.Text = fi.Name + " " + this.Text;
                        label2.Text = fi.Name;
                        label4.Text = 
                        label4.Text = ((float)fi.Length/1024).ToString() + " KB";
                        label6.Text = fi.CreationTime.ToLongDateString() + " " + fi.CreationTime.ToLongTimeString();
                        label8.Text = fi.LastWriteTime.ToLongDateString() + " " + fi.LastWriteTime.ToLongTimeString();
                        label10.Text = fi.Attributes.ToString();
                        label12.Text = FilePath;
                    }
                }
                else
                {
                    DirectoryInfo di = new DirectoryInfo(FilePath);

                    label2.Text = di.Name; 
                    label3.Visible = false;
                    label4.Visible = false;
                    label6.Text = di.CreationTime.ToLongDateString() + " " + di.CreationTime.ToLongTimeString();
                    label8.Text = di.LastWriteTime.ToLongDateString() + " " + di.LastWriteTime.ToLongTimeString();
                    label10.Text = di.Attributes.ToString();
                    label12.Text = FilePath;
                }
            }
            catch (Exception ex)
            {
                cg.WriteLogs(Logger.LogsCategory.Exception, ex);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}